﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<nelech.Models.DBModel.Track>"%>
<%@ Import Namespace="nelech.Views.Shared.Code" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    הוסף\ ערוך מסלול
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">

    <script src="../../Scripts/tinymce/jscripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>

    <script type="text/javascript">

      


        tinyMCE.init({ theme: "advanced",
            mode: "exact",
            elements: "coming, history, details, nearby",
            plugins: "",
            theme_advanced_buttons1_add_before: "forecolor,backcolor,copy,paste,fontselect", 
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_more_colors: true,
            theme_advanced_styles: "NormalBold 1=firstBold;Normal 2=first;Normal 3=second;", 
            content_css: "/Content/tinymce.css"
        });

      

    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% var db = new nelech.Models.DBModel.nelechDBEntities(); %>
    <h2>
        הוסף טיול</h2>
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm(this.Model == null ? "CreateTrack" : "EditTrack", "Admin", FormMethod.Post, new { enctype = "multipart/form-data"}))
       {%>
    <fieldset>
        <legend>שדות:</legend>
         <%
            if (Model != null)
            {
        %>
        <input type="hidden" name="number" value="<%= Model.number %>" />
        <input type="hidden" name="publish" value="1" />
        <%
            }
        %>
        <div class="right">
            <p>
                <label for="title">
                    כותרת</label>
                <%= Html.TextBox("title", this.Model == null || this.Model.title == null ? string.Empty : this.Model.title.ToString())%>
                <%= Html.ValidationMessage("title","*")%>
            </p>
            <p>
                <label for="summary">
                    תקציר:</label>
                <%= Html.TextArea("summary", this.Model == null || this.Model.summary == null ? string.Empty : this.Model.summary.ToString(), new { rows = "8", cols = "60" })%>
            </p>
            <p>
                <%= Html.LabelFor(model => model.lon)%>
                <%= Html.TextBox("lon", this.Model == null || this.Model.lon == null ? string.Empty : this.Model.lon.ToString())%>
                <%= Html.ValidationMessage("lon","*")%>
            </p>
            <p>
                <%= Html.LabelFor(model => model.lat)%>
                <%= Html.TextBox("lat", this.Model == null || this.Model.lat == null ? string.Empty : this.Model.lat.ToString())%>
                <%= Html.ValidationMessage("lat", "*")%>
            </p>
            <p>
                <%= Html.Label("km")%>
                <%= Html.TextBox("km", this.Model == null || this.Model.km == null ? string.Empty : this.Model.km.ToString())%>
            </p>
        </div>
        <div class="left">
            <p>
                <label for="annanLink">
                    לינק לעמוד ענן:</label>
                <%= Html.TextBox("annanLink", this.Model == null || this.Model.annanLink == null ? string.Empty : this.Model.annanLink.ToString())%>
            </p>
            <p>
                <label for="_regeon">
                    אזור:</label>
                <%= Html.DropDownList("_regeon", Utils.CreateRegeonListItems(this.Model == null ? null : new Nullable<int>(this.Model.Regeon1.id)))%>
            </p>
            <p>
                <label for="_circle">
                    קווי/ מעגלי:</label>
                <%= Html.DropDownList("_circle", Utils.CreateCircleItem(this.Model == null ? null : new Nullable<int>(this.Model.Circle1.id)))%>
            </p>
            <p>
                <label for="_duration">
                    משך:</label>
                <%= Html.DropDownList("_duration", Utils.CreateDurationItem(this.Model == null ? null : new Nullable<int>(this.Model.Duration1.id)))%>
            </p>
            <p>
                <label for="_time">
                    זמן:</label>
                <%= Html.DropDownList("_time", Utils.CreateTimeItem(this.Model == null ? null : new Nullable<int>(this.Model.Time1.id)))%>
            </p>
            <p>
                <label for="_difficulty">
                    רמת קושי:</label>
                <%= Html.DropDownList("_difficulty", Utils.CreateDifficultyItem(this.Model == null ? null : new Nullable<int>(this.Model.Difficulty1.id)))%>
            </p>
            <p>
                <label for="_traffic">
                    תחבורה:</label>
                <%
                    foreach (var traffic in db.Traffic)
                    {
                        Response.Write(Html.CheckBox("traffic" + traffic.id.ToString(), Model != null && Model.Traffic != null && Model.Traffic.Contains(traffic, new TrafficComparer())));
                        Response.Write(traffic.text);
                    }
                %>
            </p>
            <p>
                <label for="_season">
                    עונה:</label>
                <%
                    foreach (var season in db.Season)
                    {
                        Response.Write(Html.CheckBox("season" + season.id.ToString(), Model != null && Model.Season != null && Model.Season.Contains(season, new SeasonComparer())));
                        Response.Write(season.text);
                    }
                %>
            </p>
            <p>
                <label for="_subject">
                    נושא:</label>
                <%
                    foreach (var subject in db.Subject)
                    {
                        Response.Write(Html.CheckBox("subject" + subject.id.ToString(), Model != null && Model.Subject != null && Model.Subject.Contains(subject, new SubjectComparer())));
                        Response.Write(subject.text);
                    }
                %>
            </p>
            <p>
                <label for="_cost">
                    עלות:</label>
                <%= Html.DropDownList("_cost", Utils.CreateCostListItems(this.Model == null ? null : new Nullable<int>(this.Model.Cost1.id)))%>
            </p>
            <p>
                <label for="water">
                    מים:</label>
                <%= Html.DropDownList("water", Utils.CreateWaterListItems(this.Model == null ? null : this.Model.water))%>
            </p>
             <p>
           <label for="chackted">
                    נבדק לאחרונה:</label>
                <%= Html.TextBox("chackted", this.Model == null || this.Model.chackted == null ? string.Empty : this.Model.chackted.ToString())%>
     
        </p>
            <p>
                <label for="warning">
                    דגשים נוספים:</label><br />
                <%= Html.TextArea("warning", this.Model == null ? string.Empty : this.Model.warning, new { rows = "10", cols = "40" })%>
            </p>
        </div>
        <div class="right">
            <p class="mce">
                <label for="coming">
                    דרכי הגעה:</label><br />
                <%= Html.TextArea("coming", new { rows = "15", cols = "60", id = "coming" })%>
            </p>
            <p class="mce">
                <label for="history">
                    מידע כללי:</label><br />
                <%= Html.TextArea("history", new { rows = "15", cols = "80", id = "history" })%>
            </p>
            <p class="mce">
                <label for="details">
                    פרטים</label><br />
                <%= Html.TextArea("details", new { rows = "25", cols = "80", id = "details" })%>
                <%= Html.ValidationMessage("detail", "*") %>
            </p>
            <p class="mce">
                <label for="nearby">
                    טיולים קרובים:</label><br />
                <%= Html.TextArea("nearby", new { rows = "15", cols = "80", id = "nearby" })%>
                <%= Html.ValidationMessage("nearby", "*") %>
            </p>
            <p>
                <label for="map">
                    מפה:</label>
                <%
                    if (Model != null && !string.IsNullOrEmpty(Model.map))
                    {
                %>
                <img class="thumbs" src="<%= Model.map %>" />
                <a href="/Admin/RemoveTrackMap/<%= Model.number %>">מחק</a>
                <%
                    }
                    else
                    {
                %>
                <input type="file" name="map" size="40" />
                <%
                    } 
                %>
            </p>
            <%
                IEnumerator<nelech.Models.DBModel.Image> enm = null;
                if (Model != null)
                {
                    enm = Model.Image.GetEnumerator();
                }
                for (int i = 1; i < 11; i++)
                {
            %>
            <p>
                <%
                    if (enm != null && enm.MoveNext())
                    {
                %>
                <label for="imagePath<%= i %>">
                    <%= enm.Current.text %>:
                </label>
                <br />
                <img class="thumbs" src="<%= enm.Current.path %>" />
                <a href="/Admin/RemoveImage/<%= enm.Current.id %>">מחק</a>
                <%
                    }
                    else
                    {
                %>
                <label for="imagePath<%= i %>">
                    תמונה:
                </label>
                <input type="file" name="imagePath<%= i %>" size="40" /><br />
                <label for="imageLabel<%= i %>">
                    כיתוב:</label>
                <input type="text" name="imageLabel<%= i %>" size="40" />
                <%
                    }
                %>
            </p>
            <%
                }
            %>
            <p>
                <input type="submit" value="צור" />
            </p>
        </div>
    </fieldset>
    <% }
    %>
    <div>
        <%=Html.ActionLink("חזור לרשימה", "ListTrack") %>
        <%=Html.ActionLink("צור מקום", "CreatePlace") %>
    </div>
    
</asp:Content>
